// pages/repairOrderForm/billSelect.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    date: '2018-04-16'
  },
  bindDateChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      date: e.detail.value
    })
  },
  formSubmit: function (e) {
    console.log('form发生了submit事件，携带数据为：', e.detail.value)
    const order = e.detail.value;
    order.total = (order.price * order.weight).toFixed(2);
    order.type = 0;
    order.adder = app.globalData.openId;
    wx.request({
      url: app.globalData.baseUrl+'order/addOrder',
      data: order,
      method: "POST",
      success: function (res) {
        if (res.data.code == 0) {
          wx.navigateBack({
            complete: function () {
              wx.showToast({
                title: "修改支出成功",
                icon: "success"
              });
            }
          });
        } else {
          wx.showToast({
            title: "修改支出失败",
            icon: "fail"
          })
        }
      }
    });
  },
  formReset: function () {
    console.log('form发生了reset事件')
  }
})